#include "MultiEqualization.h"

MultiEqualization::MultiEqualization(QWidget *parent)
	: QDialog(parent)
	, ui(new Ui::MultiEqualizationClass())
{
	ui->setupUi(this);
	ConnectSlots();
}

MultiEqualization::~MultiEqualization()
{
	delete ui;
}

void MultiEqualization::ConnectSlots()
{
	connect(ui->vs_less_than_31, &QSlider::sliderMoved, this, &MultiEqualization::onSliderLessThan31Moved);
	connect(ui->vs_63, &QSlider::sliderMoved, this, &MultiEqualization::onSlider63Moved);
	connect(ui->vs_125, &QSlider::sliderMoved, this, &MultiEqualization::onSlider125Moved);

	connect(ui->vs_250, &QSlider::sliderMoved, this, &MultiEqualization::onSlider250Moved);
	connect(ui->vs_500, &QSlider::sliderMoved, this, &MultiEqualization::onSlider500Moved);
	connect(ui->vs_1k, &QSlider::sliderMoved, this, &MultiEqualization::onSlider1kMoved);
	connect(ui->vs_2k, &QSlider::sliderMoved, this, &MultiEqualization::onSlider2kMoved);
	connect(ui->vs_4k, &QSlider::sliderMoved, this, &MultiEqualization::onSlider4kMoved);
	connect(ui->vs_8k, &QSlider::sliderMoved, this, &MultiEqualization::onSlider8kMoved);
	connect(ui->vs_big_than_16k, &QSlider::sliderMoved, this, &MultiEqualization::onSliderBiggerThan16kMoved);

	connect(ui->sb_less_than_31, static_cast<void (QSpinBox::*)(int) >(&QSpinBox::valueChanged), this, &MultiEqualization::onSbLessThan31ValueChanged);
	connect(ui->sb_63, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiEqualization::onSb63ValueChanged);
	connect(ui->sb_125, static_cast<void (QSpinBox::*)(int) >(&QSpinBox::valueChanged), this, &MultiEqualization::onSb125ValueChanged);
	connect(ui->sb_250, static_cast<void (QSpinBox::*)(int) >(&QSpinBox::valueChanged), this, &MultiEqualization::onSb250ValueChanged);
	connect(ui->sb_500, static_cast<void (QSpinBox::*)(int) >(&QSpinBox::valueChanged), this, &MultiEqualization::onSb500ValueChanged);
	connect(ui->sb_1k, static_cast<void (QSpinBox::*)(int) >(&QSpinBox::valueChanged), this, &MultiEqualization::onSb1kValueChanged);
	connect(ui->sb_2k, static_cast<void (QSpinBox::*)(int) >(&QSpinBox::valueChanged), this, &MultiEqualization::onSb2kValueChanged);
	connect(ui->sb_4k, static_cast<void (QSpinBox::*)(int) >(&QSpinBox::valueChanged), this, &MultiEqualization::onSb4kValueChanged);
	connect(ui->sb_8k, static_cast<void (QSpinBox::*)(int) >(&QSpinBox::valueChanged), this, &MultiEqualization::onSb8kValueChanged);
	connect(ui->sb_big_than_16k, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiEqualization::onSbBiggerThan16kValueChanged);
	
	connect(ui->sb_gain_range, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiEqualization::onSbGianRangeChanged);

}

void MultiEqualization::onSliderLessThan31Moved(int pos)
{
	ui->sb_less_than_31->setValue(pos);
	emit EqArgs(0, 31, pos);
}

void MultiEqualization::onSlider63Moved(int pos)
{
	ui->sb_63->setValue(pos);
	emit EqArgs(1, 63, pos);
}

void MultiEqualization::onSlider125Moved(int pos)
{
	ui->sb_125->setValue(pos);
	emit EqArgs(2, 125, pos);
}

void MultiEqualization::onSlider250Moved(int pos)
{
	ui->sb_250->setValue(pos);
	emit EqArgs(3, 250, pos);
}


void MultiEqualization::onSlider500Moved(int pos)
{
	ui->sb_500->setValue(pos);
	emit EqArgs(4, 500, pos);
}

void MultiEqualization::onSlider1kMoved(int pos)
{
	ui->sb_1k->setValue(pos);
	emit EqArgs(5, 1000, pos);
}

void MultiEqualization::onSlider2kMoved(int pos)
{
	ui->sb_2k->setValue(pos);
	emit EqArgs(6, 2000, pos);
}

void MultiEqualization::onSlider4kMoved(int pos)
{
	ui->sb_4k->setValue(pos);
	emit EqArgs(7, 4000, pos);
}

void MultiEqualization::onSlider8kMoved(int pos)
{
	ui->sb_8k->setValue(pos);
	emit EqArgs(8, 8000, pos);
}

void MultiEqualization::onSliderBiggerThan16kMoved(int pos)
{
	ui->sb_big_than_16k->setValue(pos);
	emit EqArgs(9, 16000, pos);
}

void MultiEqualization::onSbLessThan31ValueChanged(int value)
{
	ui->vs_less_than_31->setValue(value);
	emit EqArgs(0, 31, value);
}

void MultiEqualization::onSb63ValueChanged(int value)
{
	ui->vs_63->setValue(value);
	emit EqArgs(1, 63, value);
}

void MultiEqualization::onSb125ValueChanged(int value)
{
	ui->vs_125->setValue(value);
	emit EqArgs(2, 125, value);
}

void MultiEqualization::onSb250ValueChanged(int value)
{
	ui->vs_250->setValue(value);
	emit EqArgs(3, 250, value);
}

void MultiEqualization::onSb500ValueChanged(int value)
{
	ui->vs_500->setValue(value);
	emit EqArgs(4, 500, value);
}

void MultiEqualization::onSb1kValueChanged(int value)
{
	ui->vs_1k->setValue(value);
	emit EqArgs(5, 1000, value);
}

void MultiEqualization::onSb2kValueChanged(int value)
{
	ui->vs_2k->setValue(value);
	emit EqArgs(6, 2000, value);
}

void MultiEqualization::onSb4kValueChanged(int value)
{
	ui->vs_4k->setValue(value);
	emit EqArgs(7, 4000, value);
}

void MultiEqualization::onSb8kValueChanged(int value)
{
	ui->vs_8k->setValue(value);
	emit EqArgs(8, 8000, value);
}

void MultiEqualization::onSbBiggerThan16kValueChanged(int value)
{
	ui->vs_big_than_16k->setValue(value);
	emit EqArgs(9, 16000, value);
}

void MultiEqualization::onSbGianRangeChanged(int value)
{
	int max = value / 2;
	int min = -1 * max;
	ui->vs_less_than_31->setRange(min, max);
	ui->vs_63->setRange(min, max);
	ui->vs_125->setRange(min, max);
	ui->vs_250->setRange(min, max);
	ui->vs_500->setRange(min, max);
	ui->vs_1k->setRange(min, max);
	ui->vs_2k->setRange(min, max);
	ui->vs_4k->setRange(min, max);
	ui->vs_8k->setRange(min, max);
	ui->vs_big_than_16k->setRange(min, max);

	ui->sb_less_than_31->setRange(min, max);
	ui->sb_63->setRange(min, max);
	ui->sb_125->setRange(min, max);
	ui->sb_250->setRange(min, max);
	ui->sb_500->setRange(min, max);
	ui->sb_1k->setRange(min, max);
	ui->sb_2k->setRange(min, max);
	ui->sb_4k->setRange(min, max);
	ui->sb_8k->setRange(min, max);
	ui->sb_big_than_16k->setRange(min, max);

}
